Python Camera.capture方法代码示例

您所在的位置:网站首页 camera capture Python Camera.capture方法代码示例

Python Camera.capture方法代码示例

2023-05-26 22:30| 来源: 网络整理| 查看: 265

本文整理汇总了Python中SimpleCV.Camera.capture方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.capture方法的具体用法?Python Camera.capture怎么用?Python Camera.capture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleCV.Camera的用法示例。

在下文中一共展示了Camera.capture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: Exception # 需要导入模块: from SimpleCV import Camera [as 别名] # 或者: from SimpleCV.Camera import capture [as 别名] raise Exception(port + " does not exist!") try: connection = serial.Serial(port, 115200, timeout=None) # serial port which blocks forever on read except: logger.exception("Error opening serial port for pinch roller arduino: %s" % (port,)) raise logger.debug("Serial initialised to port: %s \n" % (port,)) # The main loop while True: try: width = 0 if PI_CAM: # cam.capture(stream,'jpeg', use_video_port=True) with parray.PiRGBArray(cam) as output: cam.capture(output, 'rgb', use_video_port=True) img = Image(output.array).rotate(angle = 90, fixed=False).toGray() else: img = cam.getImage() #edge detect output = img.edges(t1=pixel_threshold, t2=4*pixel_threshold) #split screen result = halfsies(img,output) #find the edges upper_edge = [] lower_edge = [] for x in range(0,img.width):开发者ID:nseymoursmith,项目名称:pinch_roller,代码行数:33,代码来源:sensor.py 示例2: __init__ # 需要导入模块: from SimpleCV import Camera [as 别名] # 或者: from SimpleCV.Camera import capture [as 别名] class MyCamera: """Class to download images from an http enabled or USB camera (so could actually be any web server)""" _cam = None def __init__(self, cfg, strCamera = "basic"): """Create an instance of this class. Arguments: strCamera - The key identifying the camera to use, this camera must be defined in the config file. This key will be resolved to 'cameras.' + strCamera (e.g. cameras.dads_camera) """ self.logger = logging.getLogger(self.__class__.__name__) self.cfg_root = cfg self.cfg = cfg["cameras"][strCamera] self.cfg.setdefault("local_path", "./images/shot.jpg") self.cfg.setdefault("no_pic", "./images/xxx.jpg") self.cfg.setdefault("uri", None) if (self.cfg["uri"] == "PICAMERA"): self.logger.info ("Using connected Pi camera module ...") if (self._cam == None): self._cam = picamera.PiCamera() self._cam.resolution = (640, 480) #self._cam.start_preview() elif (self.cfg["uri"] != None): self.logger.info ("Using web camera at URI: %s ...", self.cfg["uri"]) else: self.logger.info ("Attempting to use local (USB?) camera ...") if ( self._cam == None): self._cam = Camera() def _takePiCameraPicture (self): self.logger.debug("started") #self._cam = picamera.PiCamera() #time.sleep(2) #self.logger.debug("slept for 2 seconds") f = io.BytesIO() self.logger.debug("about to capture ...") self._cam.capture(f, 'jpeg') self.logger.debug("finished") return bytearray(f.getvalue()) def _takeUSBCameraPicture (self): self.logger.debug("started") self._img = self._cam.getImage() self.logger.debug("captured image") f = io.BytesIO() self.logger.debug("XXX") self._img.getPIL().save(f,"JPEG") self.logger.debug("got byte array") return bytearray(f.getvalue()) def _takeWebCameraPicture (self): """Take a picture from the HTTP enabled camera.""" self.str = (urllib.urlopen(self.cfg["uri"])).read() self.logger.info("Picture taken on '%s'", self.cfg["uri"]) return bytearray(self.str) def takePicture(self): try: if (self.cfg["uri"] == None): self.bytes = self._takeUSBCameraPicture() elif (self.cfg["uri"] == "PICAMERA"): self.bytes = self._takePiCameraPicture() else: self.bytes = self._takeWebCameraPicture() except: e = sys.exc_info()[0] self.logger.warning ( "Failed to take picture - '%s' ... using '%s' instead.", str(e), self.cfg["no_pic"]) self.str = open(self.cfg["no_pic"]).read() self.bytes = bytearray(self.str) #raise return self.bytes def getString (self): return self.str def getByteArray (self): """Return the picture that has been taken as an array of bytes.""" return self.bytes def forwardSSHServer (self, strServer = 'localhost'): """Forward (copy) the picture that has been taken to the specified server using SSH.""" cfg = self.cfg_root["ssh_destinations"][strServer] #.........这里部分代码省略......... 开发者ID:DarfieldChris,项目名称:MinePi,代码行数:103,代码来源:camera.py

注:本文中的SimpleCV.Camera.capture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3